home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------
-
- AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
- Mail Service Access Module
-
- written by Steve Falkenburg-- MacDTS
- ©1991-1993 Apple Computer, Inc.
-
- --------------
- change history
- --------------
-
- SJF 02/19/93 update for beta build b1
- SJF 10/29/92 update to a11 a11
- SJF 06/08/92 update to a8 a8
- SJF 02/15/92 first working version a4.5
- SJF 10/16/91 initial coding a3
-
- ---------------------------------------------------------------------*/
-
- #ifndef __OCE__
- #include <OCE.h>
- #endif
-
- #ifndef __OCEMAIL__
- #include <OCEMail.h>
- #endif
-
- #include "const.h"
- #include "gwerrors.h"
- #include "mytypes.h"
- #include "globals.h"
- #include "utils.h"
- #include "gatewaystuff.h"
- #include "spoolfromexternal.h"
- #include "authstuff.h"
- #include "errorhandling.h"
-
- #include "gatewayput.h"
-
-
- // PeriodicCheckPut
- //
- // when the toolbox thinks that it's time to check for mail, this function is called, in addition
- // to being called on startup of the gateway
- //
- OSErr PeriodicCheckPut(void)
- {
- short slotIndex,arrIndex;
- SlotSpec *slotSpec;
- OSErr err = noErr;
- unsigned long dateTime;
-
- TraceExecution("\pPeriodicCheckPut");
-
- GetDateTime(&dateTime);
-
- for (slotIndex = arrIndex = 0; (err==noErr) && (slotIndex<gNumSlots); arrIndex++) {
- if ((gLocation != 0) && (gSlotDatabase[arrIndex].locationActive & MailLocationMask(gLocation))
- && gSlotDatabase[arrIndex].enabled) { // if the slot is in use, process it
- slotIndex++;
- slotSpec = &gSlotDatabase[arrIndex];
- if (slotSpec->dirIdentity.valid) {
- EnterAuthCriticalSection(); // don't allow locking of local identity while we're here
- if (TimeToCheckPut(&slotSpec->stdInfo.sendReceiveTimer,slotSpec->lastCheckPut,dateTime)) {
- err = DoSlotPut(slotSpec);
- err = RetrySlotError(err,slotSpec,true);
- if (err==noErr)
- slotSpec->lastCheckPut = dateTime;
- }
- ExitAuthCriticalSection();
- }
- }
- else slotIndex++; // index past slots that are disabled
- }
- return err;
- }
-
-
- // TimeToCheckPut
- //
- // returns true if it's time to check for mail. this function assumes the mailtimers are
- // in minutes, not seconds, since this seems to be what the toolbox is using for its scheduling
- // of eppcs. note that the OCEMail.h header file specifies that these values are in seconds.
- //
- Boolean TimeToCheckPut(MailTimers *mailTimer,unsigned long lastCheck,unsigned long curTime)
- {
- DateTimeRec dtRec;
- unsigned long midnightSecs;
-
- switch (mailTimer->receiveTimeKind) {
- case kMailTimerOff:
- return false; // never check if there is no interval
- break;
- case kMailTimerFrequency: // check if past frequency+lastCheck
- if (mailTimer->receive.frequency==0)
- return false;
- return ((lastCheck + (60*mailTimer->receive.frequency))<curTime);
- break;
- case kMailTimerTime: // check at a specific time
- if ((lastCheck + kOneDaySecs) > curTime)
- return false;
- Secs2Date(curTime,&dtRec); // get date of last midnight
- dtRec.hour = 0;
- dtRec.minute = 0;
- dtRec.second = 0;
- Date2Secs(&dtRec,&midnightSecs);
- return ( (midnightSecs+(60*mailTimer->receive.connectTime)) > curTime );
- break;
- }
- return false;
- }
-